package com.paas.form.core.element.control.impl.searchItem;

import com.paas.common.util.StringUtil;
import com.paas.form.core.element.control.FormItem;
import com.paas.form.core.element.field.FieLdsModel;
import com.paas.form.core.element.jsContent.ScriptContent;
import lombok.Data;


@Data
public class DepSelectMul implements FormItem {
    private FieLdsModel field;
    private String htmlType;
    public static final String POS_SELECT_MUL ="<dep-select v-model=\"${formObject}.${field.vModel}\" placeholder=\"请选择${field.config.label}\" clearable\n" +
            "                class=\"item\" selectType=\"${field.selectType}\" :ableDepIds=\"${field.ableDepIds}\"\n" +
            "                :multiple=\"${field.multiple}\" />";


    public String getPosSelectMul(FieLdsModel field){
        String posSeltctMulStr= "<dep-select v-model=\"${formObject}.${field.vModel}\" placeholder=\"请选择${field.config.label}\" clearable\n" +
                "                class=\"item\" selectType=\"${field.selectType}\" :multiple=\"${field.multiple}\"   ";
        if(StringUtil.isNotEmpty(field.getAbleDepIds())){
            posSeltctMulStr= posSeltctMulStr +"  :ableDepIds=\"" +field.getAbleDepIds().replaceAll("\"","'") +"\"";
        }
        posSeltctMulStr = posSeltctMulStr +"  />";
        return posSeltctMulStr;
    }


    public DepSelectMul(FieLdsModel field, String htmlType){
        this.field = field;
        this.htmlType = htmlType;

    }


    @Override
    public String makeVue() {
        return getPosSelectMul(this.field);
    }

    @Override
    public ScriptContent makeJs() {
        return null;
    }
}
